package com.example.otto.mapper;

import com.example.otto.DTO.CommentDTO;
import com.example.otto.entity.Manager;
import com.example.otto.entity.Task;
import com.example.otto.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    @Select("select * from user")
    List<User> findAll();

    @Delete("delete * from user where id = #{id}}")
    int deleteById(Integer id);

    @Select("select * from user limit #{pageNum},#{pageSize}")
    List<User> selectPage(Integer pageNum, Integer pageSize);

    @Insert("insert into user(id, username, password) values (#{id}, #{username}, #{password})")
    int insert(User user);

    int update(User user);

    @Select("select * from user where username = #{username} and password = #{password}")
    User login(String username, String password);

    @Select("select * from task where userId = #{id}")
    List<Task> searchTask(Integer id);

    @Update("update task set comment = #{comment} where num = #{num}")
    boolean submitComment(CommentDTO commentDTO);
}
